#include "color.h"
#include <iostream>
#include <cstdlib>

namespace Splatit {

Color::Color(const double _red,const double _green,const double _blue,const double _alpha) :red(_red), green(_green), blue(_blue), alpha(_alpha) 
{ }

Color::Color(void) : red(0.0) , green(0.0) , blue(0.0) , alpha(0.0) { }

Color::Color(const Color& _color) : red(_color.red) , green(_color.green) , blue(_color.blue) , alpha(_color.alpha) { }

Color::~Color(void) { }

void Color::show(void) const { std::cout << "(" << red << "," << green << "," << blue << "," << alpha << ")" << std::endl; }

Color& Color::operator=(const Color& _color) {
	if(this != &_color) {
		red = _color.red;
		blue = _color.blue;
		green = _color.green;
		alpha = _color.alpha;
	}
	return *this;
}

const double Color::operator[](const int& _index) const {
	switch(_index) {
		case 1: return red;
		case 2: return green;
		case 3: return blue;
		case 4: return alpha;
		default: exit(1);
	}
}

const Color Color::operator+(const Color& _color) const {
    return Color(red + _color.red,green + _color.green,blue + _color.blue,alpha + _color.alpha);
}

const Color Color::operator-(const Color& _color) const {
	return Color(red - _color.red,green - _color.green,blue - _color.blue,alpha - _color.alpha);
}

const Color Color::operator*(const Color& _color) const {
    return Color(red * _color.red,green * _color.green,blue * _color.blue,alpha * _color.alpha);
}
 
Color operator*(const Color& _color,const double _value) {
	return Color(_color.red* _value,_color.green * _value,_color.blue * _value,_color.alpha * _value);
}
Color operator*(const double _value,const Color& _color) {
	return _color*_value;
}

}
